package co.edu.usbcali.banco.modelo.dto;

import co.edu.usbcali.banco.modelo.Banco;
import co.edu.usbcali.banco.presentation.backEndBeans.BancoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class BancoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String nombrebanco;
    private String presidentebanco;
    private String codigobanco;
    private boolean rowSelected = false;
    private BancoView bancoView;
    private Banco banco;

    public Banco getBanco() {
        return banco;
    }

    public String listener_update(ActionEvent e) {
        try {
            bancoView.action_modifyWitDTO(((codigobanco == null) ||
                codigobanco.equals("")) ? null : new String(codigobanco),
                ((nombrebanco == null) || nombrebanco.equals("")) ? null
                                                                  : new String(
                    nombrebanco),
                ((presidentebanco == null) || presidentebanco.equals(""))
                ? null : new String(presidentebanco));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        codigobanco = banco.getCodigobanco().toString();
        nombrebanco = (banco.getNombrebanco() != null)
            ? banco.getNombrebanco().toString() : null;
        presidentebanco = (banco.getPresidentebanco() != null)
            ? banco.getPresidentebanco().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        codigobanco = banco.getCodigobanco().toString();
        nombrebanco = (banco.getNombrebanco() != null)
            ? banco.getNombrebanco().toString() : null;
        presidentebanco = (banco.getPresidentebanco() != null)
            ? banco.getPresidentebanco().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setBanco(Banco banco) {
        this.banco = banco;
    }

    public BancoView getBancoView() {
        return bancoView;
    }

    public void setBancoView(BancoView bancoView) {
        this.bancoView = bancoView;
    }

    public String getNombrebanco() {
        return nombrebanco;
    }

    public void setNombrebanco(String nombrebanco) {
        this.nombrebanco = nombrebanco;
    }

    public String getPresidentebanco() {
        return presidentebanco;
    }

    public void setPresidentebanco(String presidentebanco) {
        this.presidentebanco = presidentebanco;
    }

    public String getCodigobanco() {
        return codigobanco;
    }

    public void setCodigobanco(String codigobanco) {
        this.codigobanco = codigobanco;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
